package dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import  dao.IDao;
import  dao.inter.IAccountDao;
import  entity.Account;

@Repository
public class AccountDaoImpl implements IAccountDao {

	@Autowired
	private IDao<Account> daoImpl;
	@Override
	public boolean delete(String rowid) {
		return daoImpl.delete(Account.class, rowid);
	}

	@Override
	public Account queryById(String rowid) {
		return daoImpl.queryById(Account.class, rowid);
	}

	@Override
	public Account save(Account obj) {
		return daoImpl.save(obj);
	}

	@Override
	public boolean update(Account obj) {
		return daoImpl.update(obj);
	}

	@Override
	public List<Account> queryBySql(String sql) {
		return daoImpl.queryBySql(Account.class,sql);
	}
	@Override
	public Account queryByAccount(String account){
		HibernateTemplate ht=daoImpl.getHibernateTemplate();
		String hql="from Account where account=?";
		List<Account> accountList=ht.find(hql, account);
		if(accountList!=null&&accountList.size()!=0){
			return accountList.get(0);
		}else{
			return null;
		}
	}

	@Override
	public List<Account> queryByHql(String hql, Object[] values) {
		// TODO Auto-generated method stub
		return daoImpl.queryByHql(hql, values);
	}
}
